package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.Details;
import com.ysd.util.DBManager;

public class TuJianProductDaoImpl {

	public List<Details> getTuJian(){
		List<Details> deList = new ArrayList<Details>();
		//建立连接
		Connection conn = DBManager.getConnection();
		//增大其作用域
		Statement st = null;
		ResultSet rs = null;
		try {//正常
			//创建Statement对象
			st = conn.createStatement();
			//执行sql语句,并返回结果集
			rs = st.executeQuery("select * from details order by rand() limit 6");
			//遍历结果集
			while(rs.next()) {
				int fishId = rs.getInt("fishId");
				String fishName = rs.getString("fishName");
				String fishPicture = rs.getString("fishPicture");
				Details deta = new Details(fishId, fishName, fishPicture);
				deList.add(deta);
			}
			return deList;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		} finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
